#include <iostream>
#include <cmath>

using namespace std;

#include "cgal_helper.h"
#include "DiamondTest.h"

#define ANGLE 39.1304347

DiamondTest::DiamondTest(Point &p1, Point &p2, Point &p3): _p1(&p1), _p2(&p2), _p3(&p3) {
  _n  = Plane(p1, p2, p3).orthogonal_vector();
}

bool DiamondTest::testPoint(Point t1) {
  Vector p_1  = Plane(*_p1, *_p2, t1).orthogonal_vector();
  Vector p_2  = Plane(*_p2, *_p3, t1).orthogonal_vector();
  FT angle;
  angle = acos((p_1*p_2)/sqrt((p_1.squared_length()*p_2.squared_length())))*180/PI;

  if (angle >= ANGLE)
    return false;
  return true;
}

Oriented_side DiamondTest::getOrientation(Point t) {
  return Plane(*_p1, *_p2, *_p3).oriented_side(t);
}

